/**
 * TDS PEC 4
 * Grupo 3H2M 
 *
 * El paquete <code>edu.uoc.tds.pec4.conexion</code> agrupa todas las
 * interfaces, clases y elementos de la GUI para el control del subsistema de Conexion
 */
package edu.uoc.tds.pec4.conexion;

import edu.uoc.tds.pec4.common.util.TDSLanguageUtils;

/**
 * La clase <code>CantidadSolicitud</code> representa la interfaz de
 * usuario para introducir la cantidad solicitada sobre un equipamiento<br />
 *
 * Interficie de usuario para introducir cantidad de equipamiento seleccionado.
 *
 * @author	Jaime Marcos de la Calle
 * @version	28/11/2011
 */
public class CantidadSolicitud extends javax.swing.JDialog {

    Integer cantidad = 0;

    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabelTexto;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextFieldCantidad;
    
    /**
     * Constructor
     * 
     * @param parent padre de este JDialog
     * @param modal indica si es modal este JDialog
     */
    public CantidadSolicitud(DialogSolicitudEspacio parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public CantidadSolicitud(){

    }
    
    
    private Integer getCantidad (){
        return cantidad;
    }
    
    
    private void setCantidad (){
        cantidad = Integer.parseInt(jTextFieldCantidad.getText());
    }
    
    /**
     * Este método inicializa el interfaz gráfico de la clase
     *
     */
     private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTextFieldCantidad = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabelTexto = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(TDSLanguageUtils.getMessage("cantidadsolicitud.titulo")));

        jButton1.setText(TDSLanguageUtils.getMessage("cantidadsolicitud.aceptar"));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabelTexto.setText(TDSLanguageUtils.getMessage("cantidadsolicitud.label"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelTexto, javax.swing.GroupLayout.PREFERRED_SIZE, 331, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(156, 156, 156)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTextFieldCantidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE))
                .addContainerGap(168, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabelTexto)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextFieldCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }

      /**
      * Este método arranca cuando se pulsa el boton de Aceptar.
      * para grabar la cantidad pasada en variable.
      *
      */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        setCantidad();
        dispose();
    }
}
